<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>render函数</title>
</head>

<body>
    <main id="app">
        <h2>使用子组件</h2>
        <sub-component :level="1">
            我是标题
        </sub-component>
        <sub-component :level="2">
            我是标题
        </sub-component>
    </main>
</body>
<script src="../vue.js"></script>
<script>
    Vue.component("sub-component", {
        
        render(createElement) {
            return createElement("h" + this.level,this.$slots.default)
        },
        props: {
            level: {
                type: Number,
                default: 1
            }
        }
    });

    new Vue({
        el: "#app"
    })
</script>

</html>